<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>发布求职</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <style>
        #info .aui-list {
            background-image: none;
        }

        #info .aui-list .aui-list-item {
            padding-left: 0;
            margin: .5rem .75rem 0;
        }

        #info .aui-list .aui-list-item:last-child {
            margin: 0;
            border-bottom: .5rem solid #f6f6f6;
            padding: .5rem .75rem 0;
            background-image: none;
        }

        #info .aui-list .aui-list-item-inner {
            align-items: flex-end;
            -webkit-align-items: flex-end;
            padding-right: 0.3rem;
        }

        #info .aui-list.aui-list-in .aui-list-item {
            background-position: 0 bottom;
        }

        #info input {
            text-align: right;
        }

        #info .aui-list-item-input {
            padding-right: 0;
        }

        #details {
            margin: 0 .75rem;
        }

        #details .details_list_item {
            margin-top: 1rem;
        }

        #details .column_h {
            border-left: 0.2rem solid #0689FB;
            padding-left: 0.4rem;
            font-size: .9rem;
            margin-bottom: 0.5rem;
        }

        #details .textarea {
            width: 100%;
            height: 6rem;
            border: 1px solid #E1E1E1;
            padding: 0.2rem;
        }

        .sub {
            background: #0689FB;
            padding: .75rem 1rem;
            color: white;
            width: 40%;
            text-align: center;
            margin: 3rem auto 0;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content" id="info">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            标题描述
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="控制在20个字符左右" v-model="info.title">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" @click="openCity()">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            意向区域
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="请选择" disabled="" v-model="info.region">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">详细地址</div>
                        <div class="aui-list-item-input">
                            <input v-model="info.address" type="text" placeholder="请输入详细地址">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            联系人
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="请填写姓名" v-model="info.contact">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            联系方式
                        </div>
                        <div class="aui-list-item-input">
                            <input type="tel" placeholder="请认真填写，以便用户拨号" v-model="info.contact_phone">
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="aui-content" id="details">
            <div class="details_list_item">
                <div class="column_h">详情描述</div>
                <textarea name="" class="textarea" placeholder="请输入文字介绍" v-model="info.work_summary"></textarea>
            </div>
        </div>

        <div @click="submit()" class="sub">立即发布</div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/check.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();

        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userRegion: {},
            info: {
                user_id: '',
                title: '',
                longitude: '',
                latitude: '',
                contact: '',
                contact_phone: '',
                region_provinceid: '',
                region_cityid: '',
                region_areaid: '',
                region: '',
                address: '',
                work_summary: ''
            },
        },
        methods: {
            init() {
                this.userRegion = get_local('user_region');
                this.info.longitude = this.userRegion.lon;
                this.info.latitude = this.userRegion.lat;
                var userInfo = get_local('userInfo');
                this.info.user_id = userInfo.user_id;
            },
            openWin(name) {
                var winInfo = {
                    particulars: {
                        name: 'particulars_win',
                        url: './particulars_win.html'
                    },
                };
                if (name) {
                    open_w(winInfo[name].name, winInfo[name].url);
                } else {
                    $toast("正在开发中...");
                }
            },
            submit() {
                if (!is_define(this.info.title)) {
                    $toast("请输入标题描述");
                    return;
                } else if (!is_define(this.info.region)) {
                    $toast('请选择意向区域');
                    return;
                } else if (!is_define(this.info.address)) {
                    $toast('请输入详细地址');
                    return;
                } else if (!is_define(this.info.contact)) {
                    $toast('请输入联系人');
                    return;
                } else if (!checkMobile(this.info.contact_phone)) {
                    $toast('请输入有效的联系方式');
                    return;
                } else if (!is_define(this.info.work_summary)) {
                    $toast('请输入详情描述');
                    return;
                }
                _ajax(Config.api.ShortCreate, this.info, function(res) {
                    if (res.code === 200) {
                        $toast('发布成功!');
                        setTimeout(function() {
                            close_w();
                        }, 1000);
                    } else {
                        $toast(res.msgs);
                    }
                });
            },
            openCity() {
                api.openFrame({
                    name: 'mask',
                    url: '../../city/city_win.html',
                    rect: {
                        x: 0,
                        y: api.winHeight - api.frameHeight,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0.5)',
                    pageParam: {
                        name: api.winName,
                        frameName: api.frameName
                    }
                });
            }
        }
    });

    function setCity(province, city, area) {
        vm.info.region_provinceid = province.code;
        vm.info.region_cityid = city.code;
        vm.info.region_areaid = area.code;

        vm.info.region = province.name + '-' + city.name + '-' + area.name;
    }
</script>

</html>
